/*
 * A simple ToDo Manager
 *
 * Copyright (c) 2011 Nosheen Zaza, Manuel Rebollo, Seyedsaeid Mahpeikar and
 * Wo Ke
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */

package todomanager.ui;

import java.awt.ComponentOrientation;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;


/**
 * This is the main menu of the application
 * @author
 * Manuel Rebollo
 */
public class ToDoMenuBar extends JMenuBar{
    private JMenu fileMenu;
    private JMenu editMenu;
    private JMenu helpMenu;
    private JMenu changeLang;

    private JMenuItem newTaskItem;
    private JMenuItem tasksTodayItem;

    private JMenuItem exitItem;
    private JMenuItem cutItem;
    private JMenuItem copyItem;
    private JMenuItem pasteItem;
    private JMenuItem lang_en;
    private JMenuItem lang_zh;
    private JMenuItem aboutItem;
    private JMenuItem howToUseItem;

    /**
     * Create and initialize an instance.
     */
    public ToDoMenuBar() {
       
        fileMenu = new JMenu(
                ActionControl.getInstance().getStringsBundle().getString("fileMenu"));
        fileMenu.setOpaque(false);
        editMenu = new JMenu(
                ActionControl.getInstance().getStringsBundle().getString("editMenu"));
        editMenu.setOpaque(false);
        helpMenu = new JMenu(
                ActionControl.getInstance().getStringsBundle().getString("helpMenu"));

        helpMenu.setOpaque(false);
        changeLang = new JMenu(
                ActionControl.getInstance().getStringsBundle().getString("changeLang"));


        lang_en = new JMenuItem();
        lang_zh = new JMenuItem();

        newTaskItem = new JMenuItem(
                ActionControl.getInstance().getNewTaskAction());
        tasksTodayItem = new JMenuItem(
                ActionControl.getInstance().getTasksTodayAction());
        exitItem = new JMenuItem(
                ActionControl.getInstance().getExitAction());

        cutItem = new JMenuItem(ActionControl.getInstance().getCutAction());
        copyItem = new JMenuItem(ActionControl.getInstance().getCopyAction());
        pasteItem = new JMenuItem(ActionControl.getInstance().getPasteAction());
        lang_en = new JMenuItem(ActionControl.getInstance().getToEnglishAction());
        lang_zh = new JMenuItem(ActionControl.getInstance().getToKurdishAction());
        aboutItem = new JMenuItem(ActionControl.getInstance().getAboutAction());
        howToUseItem = new JMenuItem(ActionControl.getInstance().getHowToUseAction());


        fileMenu.add(newTaskItem);
        fileMenu.add(tasksTodayItem);
        fileMenu.add(exitItem);
        editMenu.add(cutItem);
        editMenu.add(copyItem);
        editMenu.add(pasteItem);
        editMenu.add(changeLang);
        changeLang.add(lang_en);
        changeLang.add(lang_zh);
        helpMenu.add(aboutItem);
        helpMenu.add(howToUseItem);

        /**
         * The foloowing text and mnemonic settings are here since, it makes no
         * much sense to create actions for components that perform no actions.
         */
        fileMenu.setText(
                ActionControl.getInstance().getStringsBundle().getString("fileMenu"));
        editMenu.setText(
                ActionControl.getInstance().getStringsBundle().getString("editMenu"));
        helpMenu.setText(
                ActionControl.getInstance().getStringsBundle().getString("helpMenu"));


        fileMenu.setMnemonic(
                Integer.valueOf(ActionControl.getInstance().getStringsBundle().getString(
                "fileMenuMnemonic").charAt(0)));
        editMenu.setMnemonic(
                Integer.valueOf(ActionControl.getInstance().getStringsBundle().getString(
                "editMenuMnemonic").charAt(0)));
        helpMenu.setMnemonic(
                Integer.valueOf(ActionControl.getInstance().getStringsBundle().getString(
                "helpMenuMnemonic").charAt(0)));

        exitItem.setMnemonic(
                Integer.valueOf(ActionControl.getInstance().getStringsBundle().getString(
                "exitItemMnemonic").charAt(0)));
        newTaskItem.setMnemonic(
                Integer.valueOf(ActionControl.getInstance().getStringsBundle().getString(
                "addItemMnemonic").charAt(0)));
        cutItem.setMnemonic(
                Integer.valueOf(ActionControl.getInstance().getStringsBundle().getString(
                "cutMnemonic").charAt(0)));
        copyItem.setMnemonic(
                Integer.valueOf(ActionControl.getInstance().getStringsBundle().getString(
                "copyMnemonic").charAt(0)));
        pasteItem.setMnemonic(
                Integer.valueOf(ActionControl.getInstance().getStringsBundle().getString(
                "pasteMnemonic").charAt(0)));
        aboutItem.setMnemonic(
                Integer.valueOf(ActionControl.getInstance().getStringsBundle().getString(
                "aboutMnemonic").charAt(0)));
        howToUseItem.setMnemonic(
                Integer.valueOf(ActionControl.getInstance().getStringsBundle().getString(
                "howToMnemonic").charAt(0)));
        changeLang.setMnemonic(
                Integer.valueOf(ActionControl.getInstance().getStringsBundle().getString(
                "changeLangMnemonic").charAt(0)));
        
        add(fileMenu);
        add(editMenu);
        add(helpMenu);
    }
}